package testMybatis;

import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.web.client.RestTemplate;

public class testHttp {
	protected static  RestTemplate rest = new RestTemplate();
	public static void main(String[] args) {
		String back = rest.getForObject("http://localhost:8080/SSM/service/myrest/myjson.xml", String.class);
		System.out.println(back);
		CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(HttpClientUtil.getRequestConfig(300)).build();
//		resCode = HttpClientUtil.doPost(httpClient, notifyUrl, reqContent, "application/json", encoding);
		//application/x-www-form-urlencoded是第三方的content type协议格式
		Object resCode = HttpClientUtil.doPost(httpClient, "http://localhost:8080/SSM/service/myrest/myjson.xml","" ,"application/x-www-form-urlencoded", "UTF-8");
		System.out.println(resCode);
	}
}
